/**
 *	@file	d_taya_st.c
 *	@brief	デバッグたや　常駐ソース
 *	@author	Miyuki Iwasawa
 *	@date	09.02.02
 *
 *	d_taya.cを常駐ソースと非常駐ソースに切り分け
 */

#ifdef PM_DEBUG

#include "common.h"
#include "system/lib_pack.h"
#include "system/bmp_list.h"
#include "system/wipe.h"
#include "fieldmap.h"
#include "fieldsys.h"
#include "system/fontproc.h"
#include "system/pm_str.h"
#include "system/pm_overlay.h"
#include "field_event.h"

#include "d_taya.h"
#include "d_taya_local.h"

//===================================================================================================
//===================================================================================================
extern GMEVENT_FUNC FieldEvent_GetFunc( GMEVENT_CONTROL * event );


BOOL GMEVENT_ChangeScheneDebug(GMEVENT_CONTROL * event)
{
	FIELDSYS_WORK* fsys;
	DTAYA_CHANGESCHENE_WORK* wk;

//	if( PaletteFadeCheck() != 0 ){
//		return FALSE;
//	}

	fsys = FieldEvent_GetFieldSysWork(event);
	wk = FieldEvent_GetSpecialWork(event);

	switch( wk->seq ){
	case 0:
		FieldFadeWipeSet( FLD_DISP_BRIGHT_BLACKOUT );
		wk->seq++;
		/* fallthru */
	case 1:
		if( WIPE_SYS_EndCheck() )
		{
			wk->start_func( fsys, wk->gen_wk );
			wk->seq++;
		}
		break;
	case 2:
		if (FieldEvent_Cmd_WaitSubProcEnd(fsys) == FALSE) {
			FieldEvent_Cmd_SetMapProc(fsys);
			wk->seq++;
		}
		break;
	case 3:
		if (FieldEvent_Cmd_WaitMapProcStart(fsys) == FALSE) {
			FieldFadeWipeSet( FLD_DISP_BRIGHT_BLACKIN );
			wk->seq++;
		}
		break;
	case 4:
		if( WIPE_SYS_EndCheck() )
		{
			if( wk->end_func )
			{
				wk->end_func( fsys, wk->gen_wk );
			}
			sys_FreeMemoryEz(wk);
			return TRUE;
		}
		break;
	}
	return FALSE;
}


#endif	//PM_DEBUG
